home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2001 / MacHack 2001.toast / pc / The Hacks / pseudoDoc / ExampleHeaders / NoComments.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-06-23  |  31.5 KB  |  689 lines

  1. /*    CFArray.h
  2.     Copyright 1998-1999, Apple Computer, Inc. All rights reserved.
  3. */
  4.  
  5. /*
  6.     @header CFArrayConst
  7.     CFArray implements an ordered, compact container of pointer-sized
  8.     values. Values are accessed via integer keys (indices), from the
  9.     range 0 to N-1, where N is the number of values in the array when
  10.     an operation is performed. The array is said to be "compact" because
  11.     deleted or inserted values do not leave a gap in the key space --
  12.     the values with higher-numbered indices have their indices
  13.     renumbered lower (or higher, in the case of insertion) so that the
  14.     set of valid indices is always in the integer range [0, N-1]. Thus,
  15.     the index to access a particular value in the array may change over
  16.     time as other values are inserted into or deleted from the array.
  17.  
  18.     Arrays come in two flavors, immutable, which cannot have values
  19.     added to them or removed from them after the array is created, and
  20.     mutable, to which you can add values or from which remove values.
  21.     Mutable arrays have two subflavors, fixed-capacity, for which there
  22.     is a maximum number set at creation time of values which can be put
  23.     into the array, and variable capacity, which can have an unlimited
  24.     number of values (or rather, limited only by constraints external
  25.     to CFArray, like the amount of available memory). Fixed-capacity
  26.     arrays can be somewhat higher performing, if you can put a definate
  27.     upper limit on the number of values that might be put into the
  28.     array.
  29.  
  30.     As with all CoreFoundation collection types, arrays maintain hard
  31.     references on the values you put in them, but the retaining and
  32.     releasing functions are user-defined callbacks that can actually do
  33.     whatever the user wants (for example, nothing).
  34.  
  35.     Computational Complexity
  36.     The access time for a value in the array is guaranteed to be at
  37.     worst O(lg N) for any implementation, current and future, but will
  38.     often be O(1) (constant time). Linear search operations similarly
  39.     have a worst case complexity of O(N*lg N), though typically the
  40.     bounds will be tighter, and so on. Insertion or deletion operations
  41.     will typically be linear in the number of values in the array, but
  42.     may be O(N*lg N) clearly in the worst case in some implementations.
  43.     There are no favored positions within the array for performance;
  44.     that is, it is not necessarily faster access values with low
  45.     indices, or to insert or delete values with high indices, or
  46.     whatever.
  47. */
  48.  
  49. #if !defined(__COREFOUNDATION_CFARRAY__)
  50. #define __COREFOUNDATION_CFARRAY__ 1
  51.  
  52. #include <CoreFoundation/CFBase.h>
  53.  
  54. #if defined(__cplusplus)
  55. extern "C" {
  56. #endif
  57.  
  58. /*
  59.     @typedef CFArrayCallBacks
  60.     Structure containing the callbacks of a CFArray.
  61.     @field version The version number of the structure type being passed
  62.         in as a parameter to the CFArray creation functions. This
  63.         structure is version 0.
  64.     @field retain The callback used to add a retain for the array on
  65.         values as they are put into the array. This callback returns
  66.         the value to store in the array, which is usually the value
  67.         parameter passed to this callback, but may be a different
  68.         value if a different value should be stored in the array.
  69.         The array's allocator is passed as the first argument.
  70.     @field release The callback used to remove a retain previously added
  71.         for the array from values as they are removed from the
  72.         array. The array's allocator is passed as the first
  73.         argument.
  74.     @field copyDescription The callback used to create a descriptive
  75.         string representation of each value in the array. This is
  76.         used by the CFCopyDescription() function.
  77.     @field equal The callback used to compare values in the array for
  78.         equality for some operations.
  79. */
  80. typedef const void *    (*CFArrayRetainCallBack)(CFAllocatorRef allocator, const void *value);
  81. typedef void        (*CFArrayReleaseCallBack)(CFAllocatorRef allocator, const void *value);
  82. typedef CFStringRef    (*CFArrayCopyDescriptionCallBack)(const void *value);
  83. typedef Boolean        (*CFArrayEqualCallBack)(const void *value1, const void *value2);
  84. typedef struct {
  85.     CFIndex                version;
  86.     CFArrayRetainCallBack        retain;
  87.     CFArrayReleaseCallBack        release;
  88.     CFArrayCopyDescriptionCallBack    copyDescription;
  89.     CFArrayEqualCallBack        equal;
  90. } CFArrayCallBacks;
  91.  
  92. /*
  93.     @const kCFTypeArrayCallBacks
  94.     Predefined CFArrayCallBacks structure containing a set of callbacks
  95.     appropriate for use when the values in a CFArray are all CFTypes.
  96. */
  97. CF_EXPORT
  98. const CFArrayCallBacks kCFTypeArrayCallBacks;
  99.  
  100. /*
  101.     @typedef CFArrayApplierFunction
  102.     Type of the callback function used by the apply functions of
  103.         CFArrays.
  104.     @param val The current value from the array.
  105.     @param context The user-defined context parameter given to the apply
  106.         function.
  107. */
  108. typedef void (*CFArrayApplierFunction)(const void *value, void *context);
  109.  
  110. /*
  111.     @typedef CFArrayRef
  112.     This is the type of a reference to immutable CFArrays.
  113. */
  114. typedef const struct __CFArray * CFArrayRef;
  115.  
  116. /*
  117.     @typedef CFMutableArrayRef
  118.     This is the type of a reference to mutable CFArrays.
  119. */
  120. typedef struct __CFArray * CFMutableArrayRef;
  121.  
  122. /*
  123.     @function CFArrayGetTypeID
  124.     Returns the type identifier of all CFArray instances.
  125. */
  126. CF_EXPORT
  127. CFTypeID CFArrayGetTypeID(void);
  128.  
  129. /*
  130.     @function CFArrayCreate
  131.     Creates a new immutable array with the given values.
  132.     @param allocator The CFAllocator which should be used to allocate
  133.         memory for the array and its storage for values. This
  134.         parameter may be NULL in which case the current default
  135.         CFAllocator is used. If this reference is not a valid
  136.         CFAllocator, the behavior is undefined.
  137.     @param values A C array of the pointer-sized values to be in the
  138.         array. The values in the array are ordered in the same order
  139.         in which they appear in this C array. This parameter may be
  140.         NULL if the numValues parameter is 0. This C array is not
  141.         changed or freed by this function. If this parameter is not
  142.         a valid pointer to a C array of at least numValues pointers,
  143.         the behavior is undefined.
  144.     @param numValues The number of values to copy from the values C
  145.         array into the CFArray. This number will be the count of the
  146.         array.
  147.         If this parameter is negative, or greater than the number of
  148.         values actually in the values C array, the behavior is
  149.         undefined.
  150.     @param callBacks A pointer to a CFArrayCallBacks structure
  151.         initialized with the callbacks for the array to use on each
  152.         value in the array. The retain callback will be used within
  153.         this function, for example, to retain all of the new values
  154.         from the values C array. A copy of the contents of the
  155.         callbacks structure is made, so that a pointer to a
  156.         structure on the stack can be passed in, or can be reused
  157.         for multiple array creations. If the version field of this
  158.         callbacks structure is not one of the defined ones for
  159.         CFArray, the behavior is undefined. The retain field may be
  160.         NULL, in which case the CFArray will do nothing to add a
  161.         retain to the contained values for the array. The release
  162.         field may be NULL, in which case the CFArray will do nothing
  163.         to remove the array's retain (if any) on the values when the
  164.         array is destroyed. If the copyDescription field is NULL,
  165.         the array will create a simple description for the value. If
  166.         the equal field is NULL, the array will use pointer equality
  167.         to test for equality of values. This callbacks parameter
  168.         itself may be NULL, which is treated as if a valid structure
  169.         of version 0 with all fields NULL had been passed in.
  170.         Otherwise, if any of the fields are not valid pointers to
  171.         functions of the correct type, or this parameter is not a
  172.         valid pointer to a  CFArrayCallBacks callbacks structure,
  173.         the behavior is undefined. If any of the values put into the
  174.         array is not one understood by one of the callback functions
  175.         the behavior when that callback function is used is
  176.         undefined.
  177.     @result A reference to the new immutable CFArray.
  178. */
  179. CF_EXPORT
  180. CFArrayRef CFArrayCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFArrayCallBacks *callBacks);
  181.  
  182. /*
  183.     @function CFArrayCreateCopy
  184.     Creates a new immutable array with the values from the given array.
  185.     @param allocator The CFAllocator which should be used to allocate
  186.         memory for the array and its storage for values. This
  187.         parameter may be NULL in which case the current default
  188.         CFAllocator is used. If this reference is not a valid
  189.         CFAllocator, the behavior is undefined.
  190.     @param theArray The array which is to be copied. The values from the
  191.         array are copied as pointers into the new array (that is,
  192.         the values themselves are copied, not that which the values
  193.         point to, if anything). However, the values are also
  194.         retained by the new array. The count of the new array will
  195.         be the same as the given array. The new array uses the same
  196.         callbacks as the array to be copied. If this parameter is
  197.         not a valid CFArray, the behavior is undefined.
  198.     @result A reference to the new immutable CFArray.
  199. */
  200. CF_EXPORT
  201. CFArrayRef CFArrayCreateCopy(CFAllocatorRef allocator, CFArrayRef theArray);
  202.  
  203. /*
  204.     @function CFArrayCreateMutable
  205.     Creates a new empty mutable array.
  206.     @param allocator The CFAllocator which should be used to allocate
  207.         memory for the array and its storage for values. This
  208.         parameter may be NULL in which case the current default
  209.         CFAllocator is used. If this reference is not a valid
  210.         CFAllocator, the behavior is undefined.
  211.     @param capacity The maximum number of values that can be contained
  212.         by the CFArray. The array starts empty, and can grow to this
  213.         number of values (and it can have less). If this parameter
  214.         is 0, the array's maximum capacity is unlimited (or rather,
  215.         only limited by address space and available memory
  216.         constraints). If this parameter is negative, the behavior is
  217.         undefined.
  218.     @param callBacks A pointer to a CFArrayCallBacks structure
  219.         initialized with the callbacks for the array to use on each
  220.         value in the array. A copy of the contents of the
  221.         callbacks structure is made, so that a pointer to a
  222.         structure on the stack can be passed in, or can be reused
  223.         for multiple array creations. If the version field of this
  224.         callbacks structure is not one of the defined ones for
  225.         CFArray, the behavior is undefined. The retain field may be
  226.         NULL, in which case the CFArray will do nothing to add a
  227.         retain to the contained values for the array. The release
  228.         field may be NULL, in which case the CFArray will do nothing
  229.         to remove the arrays retain (if any) on the values when the
  230.         array is destroyed. If the copyDescription field is NULL,
  231.         the array will create a simple description for the value. If
  232.         the equal field is NULL, the array will use pointer equality
  233.         to test for equality of values. This callbacks parameter
  234.         itself may be NULL, which is treated as if a valid structure
  235.         of version 0 with all fields NULL had been passed in.
  236.         Otherwise, if any of the fields are not valid pointers to
  237.         functions of the correct type, or this parameter is not a
  238.         valid pointer to a  CFArrayCallBacks callbacks structure,
  239.         the behavior is undefined. If any of the values put into the
  240.         array is not one understood by one of the callback functions
  241.         the behavior when that callback function is used is
  242.         undefined.
  243.     @result A reference to the new mutable CFArray.
  244. */
  245. CF_EXPORT
  246. CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks);
  247.  
  248. /*
  249.     @function CFArrayCreateMutableCopy
  250.     Creates a new mutable array with the values from the given array.
  251.     @param allocator The CFAllocator which should be used to allocate
  252.         memory for the array and its storage for values. This
  253.         parameter may be NULL in which case the current default
  254.         CFAllocator is used. If this reference is not a valid
  255.         CFAllocator, the behavior is undefined.
  256.     @param capacity The maximum number of values that can be contained
  257.         by the CFArray. The array starts empty, and can grow to this
  258.         number of values (and it can have less). If this parameter
  259.         is 0, the array's maximum capacity is unlimited (or rather,
  260.         only limited by address space and available memory
  261.         constraints). This parameter must be greater than or equal
  262.         to the count of the array which is to be copied, or the
  263.         behavior is undefined. If this parameter is negative, the
  264.         behavior is undefined.
  265.     @param theArray The array which is to be copied. The values from the
  266.         array are copied as pointers into the new array (that is,
  267.         the values themselves are copied, not that which the values
  268.         point to, if anything). However, the values are also
  269.         retained by the new array. The count of the new array will
  270.         be the same as the given array. The new array uses the same
  271.         callbacks as the array to be copied. If this parameter is
  272.         not a valid CFArray, the behavior is undefined.
  273.     @result A reference to the new mutable CFArray.
  274. */
  275. CF_EXPORT 
  276. CFMutableArrayRef CFArrayCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFArrayRef theArray);
  277.  
  278. /*
  279.     @function CFArrayGetCount
  280.     Returns the number of values currently in the array.
  281.     @param theArray The array to be queried. If this parameter is not a valid
  282.         CFArray, the behavior is undefined.
  283.     @result The number of values in the array.
  284. */
  285. CF_EXPORT
  286. CFIndex CFArrayGetCount(CFArrayRef theArray);
  287.  
  288. /*
  289.     @function CFArrayGetCountOfValue
  290.     Counts the number of times the given value occurs in the array.
  291.     @param theArray The array to be searched. If this parameter is not a
  292.         valid CFArray, the behavior is undefined.
  293.     @param range The range within the array to search. If the range
  294.         location or end point (defined by the location plus length
  295.         minus 1) are outside the index space of the array (0 to
  296.         N-1 inclusive, where N is the count of the array), the
  297.         behavior is undefined. If the range length is negative, the
  298.         behavior is undefined. The range may be empty (length 0).
  299.     @param value The value for which to find matches in the array. The
  300.         equal() callback provided when the array was created is
  301.         used to compare. If the equal() callback was NULL, pointer
  302.         equality (in C, ==) is used. If value, or any of the values
  303.         in the array, are not understood by the equal() callback,
  304.         the behavior is undefined.
  305.     @result The number of times the given value occurs in the array,
  306.         within the specified range.
  307. */
  308. CF_EXPORT
  309. CFIndex CFArrayGetCountOfValue(CFArrayRef theArray, CFRange range, const void *value);
  310.  
  311. /*
  312.     @function CFArrayContainsValue
  313.     Reports whether or not the value is in the array.
  314.     @param theArray The array to be searched. If this parameter is not a
  315.         valid CFArray, the behavior is undefined.
  316.     @param range The range within the array to search. If the range
  317.         location or end point (defined by the location plus length
  318.         minus 1) are outside the index space of the array (0 to
  319.         N-1 inclusive, where N is the count of the array), the
  320.         behavior is undefined. If the range length is negative, the
  321.         behavior is undefined. The range may be empty (length 0).
  322.     @param value The value for which to find matches in the array. The
  323.         equal() callback provided when the array was created is
  324.         used to compare. If the equal() callback was NULL, pointer
  325.         equality (in C, ==) is used. If value, or any of the values
  326.         in the array, are not understood by the equal() callback,
  327.         the behavior is undefined.
  328.     @result TRUE, if the value is in the specified range of the array,
  329.         otherwise FALSE.
  330. */
  331. CF_EXPORT
  332. Boolean CFArrayContainsValue(CFArrayRef theArray, CFRange range, const void *value);
  333.  
  334. /*
  335.     @function CFArrayGetValueAtIndex
  336.     Retrieves the value at the given index.
  337.     @param theArray The array to be queried. If this parameter is not a
  338.         valid CFArray, the behavior is undefined.
  339.     @param idx The index of the value to retrieve. If the index is
  340.         outside the index space of the array (0 to N-1 inclusive,
  341.         where N is the count of the array), the behavior is
  342.         undefined.
  343.     @result The value with the given index in the array.
  344. */
  345. CF_EXPORT
  346. const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx);
  347.  
  348. /*
  349.     @function CFArrayGetValues
  350.     Fills the buffer with values from the array.
  351.     @param theArray The array to be queried. If this parameter is not a
  352.         valid CFArray, the behavior is undefined.
  353.     @param range The range of values within the array to retrieve. If
  354.         the range location or end point (defined by the location
  355.         plus length minus 1) are outside the index space of the
  356.         array (0 to N-1 inclusive, where N is the count of the
  357.         array), the behavior is undefined. If the range length is
  358.         negative, the behavior is undefined. The range may be empty
  359.         (length 0), in which case no values are put into the buffer.
  360.     @param values A C array of pointer-sized values to be filled with
  361.         values from the array. The values in the C array are ordered
  362.         in the same order in which they appear in the array. If this
  363.         parameter is not a valid pointer to a C array of at least
  364.         range.length pointers, the behavior is undefined.
  365. */
  366. CF_EXPORT
  367. void CFArrayGetValues(CFArrayRef theArray, CFRange range, const void **values);
  368.  
  369. /*
  370.     @function CFArrayApplyFunction
  371.     Calls a function once for each value in the array.
  372.     @param theArray The array to be operated upon. If this parameter is not
  373.         a valid CFArray, the behavior is undefined.
  374.     @param range The range of values within the array to which to apply
  375.         the function. If the range location or end point (defined by
  376.         the location plus length minus 1) are outside the index
  377.         space of the array (0 to N-1 inclusive, where N is the count
  378.         of the array), the behavior is undefined. If the range
  379.         length is negative, the behavior is undefined. The range may
  380.         be empty (length 0).
  381.     @param applier The callback function to call once for each value in
  382.         the given range in the array. If this parameter is not a
  383.         pointer to a function of the correct prototype, the behavior
  384.         is undefined. If there are values in the range which the
  385.         applier function does not expect or cannot properly apply
  386.         to, the behavior is undefined. 
  387.     @param context A pointer-sized user-defined value, which is passed
  388.         as the second parameter to the applier function, but is
  389.         otherwise unused by this function. If the context is not
  390.         what is expected by the applier function, the behavior is
  391.         undefined.
  392. */
  393. CF_EXPORT
  394. void CFArrayApplyFunction(CFArrayRef theArray, CFRange range, CFArrayApplierFunction applier, void *context);
  395.  
  396. /*
  397.     @function CFArrayGetFirstIndexOfValue
  398.     Searches the array for the value.
  399.     @param theArray The array to be searched. If this parameter is not a
  400.         valid CFArray, the behavior is undefined.
  401.     @param range The range within the array to search. If the range
  402.         location or end point (defined by the location plus length
  403.         minus 1) are outside the index space of the array (0 to
  404.         N-1 inclusive, where N is the count of the array), the
  405.         behavior is undefined. If the range length is negative, the
  406.         behavior is undefined. The range may be empty (length 0).
  407.         The search progresses from the smallest index defined by
  408.         the range to the largest.
  409.     @param value The value for which to find a match in the array. The
  410.         equal() callback provided when the array was created is
  411.         used to compare. If the equal() callback was NULL, pointer
  412.         equality (in C, ==) is used. If value, or any of the values
  413.         in the array, are not understood by the equal() callback,
  414.         the behavior is undefined.
  415.     @result The lowest index of the matching values in the range, or -1
  416.         if no value in the range matched.
  417. */
  418. CF_EXPORT
  419. CFIndex CFArrayGetFirstIndexOfValue(CFArrayRef theArray, CFRange range, const void *value);
  420.  
  421. /*
  422.     @function CFArrayGetLastIndexOfValue
  423.     Searches the array for the value.
  424.     @param theArray The array to be searched. If this parameter is not a
  425.         valid CFArray, the behavior is undefined.
  426.     @param range The range within the array to search. If the range
  427.         location or end point (defined by the location plus length
  428.         minus 1) are outside the index space of the array (0 to
  429.         N-1 inclusive, where N is the count of the array), the
  430.         behavior is undefined. If the range length is negative, the
  431.         behavior is undefined. The range may be empty (length 0).
  432.         The search progresses from the largest index defined by the
  433.         range to the smallest.
  434.     @param value The value for which to find a match in the array. The
  435.         equal() callback provided when the array was created is
  436.         used to compare. If the equal() callback was NULL, pointer
  437.         equality (in C, ==) is used. If value, or any of the values
  438.         in the array, are not understood by the equal() callback,
  439.         the behavior is undefined.
  440.     @result The highest index of the matching values in the range, or -1
  441.         if no value in the range matched.
  442. */
  443. CF_EXPORT
  444. CFIndex CFArrayGetLastIndexOfValue(CFArrayRef theArray, CFRange range, const void *value);
  445.  
  446. /*
  447.     @function CFArrayBSearchValues
  448.     Searches the array for the value using a binary search algorithm.
  449.     @param theArray The array to be searched. If this parameter is not a
  450.         valid CFArray, the behavior is undefined. If the array is
  451.         not sorted from least to greatest according to the
  452.         comparator function, the behavior is undefined.
  453.     @param range The range within the array to search. If the range
  454.         location or end point (defined by the location plus length
  455.         minus 1) are outside the index space of the array (0 to
  456.         N-1 inclusive, where N is the count of the array), the
  457.         behavior is undefined. If the range length is negative, the
  458.         behavior is undefined. The range may be empty (length 0).
  459.     @param value The value for which to find a match in the array. If
  460.         value, or any of the values in the array, are not understood
  461.         by the comparator callback, the behavior is undefined.
  462.     @param comparator The function with the comparator function type
  463.         signature which is used in the binary search operation to
  464.         compare values in the array with the given value. If this
  465.         parameter is not a pointer to a function of the correct
  466.         prototype, the behavior is undefined. If there are values
  467.         in the range which the comparator function does not expect
  468.         or cannot properly compare, the behavior is undefined.
  469.     @param context A pointer-sized user-defined value, which is passed
  470.         as the third parameter to the comparator function, but is
  471.         otherwise unused by this function. If the context is not
  472.         what is expected by the comparator function, the behavior is
  473.         undefined.
  474.     @result The return value is either 1) the index of a value that
  475.         matched, if the target value matches one or more in the
  476.         range, 2) greater than or equal to the end point of the
  477.         range, if the value is greater than all the values in the
  478.         range, or 3) the index of the value greater than the target
  479.         value, if the value lies between two of (or less than all
  480.         of) the values in the range.
  481. */
  482. CF_EXPORT
  483. CFIndex CFArrayBSearchValues(CFArrayRef theArray, CFRange range, const void *value, CFComparatorFunction comparator, void *context);
  484.  
  485. /*
  486.     @function CFArrayAppendValue
  487.     Adds the value to the array giving it the new largest index.
  488.     @param theArray The array to which the value is to be added. If this
  489.         parameter is not a valid mutable CFArray, the behavior is
  490.         undefined. If the array is a fixed-capacity array and it
  491.         is full before this operation, the behavior is undefined.
  492.     @param value The value to add to the array. The value is retained by
  493.         the array using the retain callback provided when the array
  494.         was created. If the value is not of the sort expected by the
  495.         retain callback, the behavior is undefined. The value is
  496.         assigned to the index one larger than the previous largest
  497.         index, and the count of the array is increased by one.
  498. */
  499. CF_EXPORT
  500. void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value);
  501.  
  502. /*
  503.     @function CFArrayInsertValueAtIndex
  504.     Adds the value to the array giving it the given index.
  505.     @param theArray The array to which the value is to be added. If this
  506.         parameter is not a valid mutable CFArray, the behavior is
  507.         undefined. If the array is a fixed-capacity array and it
  508.         is full before this operation, the behavior is undefined.
  509.     @param idx The index to which to add the new value. If the index is
  510.         outside the index space of the array (0 to N inclusive,
  511.         where N is the count of the array before the operation), the
  512.         behavior is undefined. If the index is the same as N, this
  513.         function has the same effect as CFArrayAppendValue().
  514.     @param value The value to add to the array. The value is retained by
  515.         the array using the retain callback provided when the array
  516.         was created. If the value is not of the sort expected by the
  517.         retain callback, the behavior is undefined. The value is
  518.         assigned to the given index, and all values with equal and
  519.         larger indices have their indexes increased by one.
  520. */
  521. CF_EXPORT
  522. void CFArrayInsertValueAtIndex(CFMutableArrayRef theArray, CFIndex idx, const void *value);
  523.  
  524. /*
  525.     @function CFArraySetValueAtIndex
  526.     Changes the value with the given index in the array.
  527.     @param theArray The array in which the value is to be changed. If this
  528.         parameter is not a valid mutable CFArray, the behavior is
  529.         undefined. If the array is a fixed-capacity array and it
  530.         is full before this operation and the index is the same as
  531.         N, the behavior is undefined.
  532.     @param idx The index to which to set the new value. If the index is
  533.         outside the index space of the array (0 to N inclusive,
  534.         where N is the count of the array before the operation), the
  535.         behavior is undefined. If the index is the same as N, this
  536.         function has the same effect as CFArrayAppendValue().
  537.     @param value The value to set in the array. The value is retained by
  538.         the array using the retain callback provided when the array
  539.         was created, and the previous value with that index is
  540.         released. If the value is not of the sort expected by the
  541.         retain callback, the behavior is undefined. The indices of
  542.         other values is not affected.
  543. */
  544. CF_EXPORT
  545. void CFArraySetValueAtIndex(CFMutableArrayRef theArray, CFIndex idx, const void *value);
  546.  
  547. /*
  548.     @function CFArrayRemoveValueAtIndex
  549.     Removes the value with the given index from the array.
  550.     @param theArray The array from which the value is to be removed. If
  551.         this parameter is not a valid mutable CFArray, the behavior
  552.         is undefined.
  553.     @param idx The index from which to remove the value. If the index is
  554.         outside the index space of the array (0 to N-1 inclusive,
  555.         where N is the count of the array before the operation), the
  556.         behavior is undefined.
  557. */
  558. CF_EXPORT
  559. void CFArrayRemoveValueAtIndex(CFMutableArrayRef theArray, CFIndex idx);
  560.  
  561. /*
  562.     @function CFArrayRemoveAllValues
  563.     Removes all the values from the array, making it empty.
  564.     @param theArray The array from which all of the values are to be
  565.         removed. If this parameter is not a valid mutable CFArray,
  566.         the behavior is undefined.
  567. */
  568. CF_EXPORT
  569. void CFArrayRemoveAllValues(CFMutableArrayRef theArray);
  570.  
  571. /*
  572.     @function CFArrayReplaceValues
  573.     Replaces a range of values in the array.
  574.     @param theArray The array from which all of the values are to be
  575.         removed. If this parameter is not a valid mutable CFArray,
  576.         the behavior is undefined.
  577.     @param range The range of values within the array to replace. If the
  578.         range location or end point (defined by the location plus
  579.         length minus 1) are outside the index space of the array (0
  580.         to N inclusive, where N is the count of the array), the
  581.         behavior is undefined. If the range length is negative, the
  582.         behavior is undefined. The range may be empty (length 0),
  583.         in which case the new values are merely inserted at the
  584.         range location.
  585.     @param newValues A C array of the pointer-sized values to be placed
  586.         into the array. The new values in the array are ordered in
  587.         the same order in which they appear in this C array. This
  588.         parameter may be NULL if the newCount parameter is 0. This
  589.         C array is not changed or freed by this function. If this
  590.         parameter is not a valid pointer to a C array of at least
  591.         newCount pointers, the behavior is undefined.
  592.     @param newCount The number of values to copy from the values C
  593.         array into the CFArray. If this parameter is different than
  594.         the range length, the excess newCount values will be
  595.         inserted after the range, or the excess range values will be
  596.         deleted. This parameter may be 0, in which case no new
  597.         values are replaced into the array and the values in the
  598.         range are simply removed. If this parameter is negative, or
  599.         greater than the number of values actually in the newValues
  600.         C array, the behavior is undefined.
  601. */
  602. CF_EXPORT
  603. void CFArrayReplaceValues(CFMutableArrayRef theArray, CFRange range, const void **newValues, CFIndex newCount);
  604.  
  605. /*
  606.     @function CFArrayExchangeValuesAtIndices
  607.     Exchanges the values at two indices of the array.
  608.     @param theArray The array of which the values are to be swapped. If
  609.         this parameter is not a valid mutable CFArray, the behavior
  610.         is undefined.
  611.     @param idx1 The first index whose values should be swapped. If the
  612.         index is outside the index space of the array (0 to N-1
  613.         inclusive, where N is the count of the array before the
  614.         operation), the behavior is undefined.
  615.     @param idx2 The second index whose values should be swapped. If the
  616.         index is outside the index space of the array (0 to N-1
  617.         inclusive, where N is the count of the array before the
  618.         operation), the behavior is undefined.
  619. */
  620. CF_EXPORT
  621. void CFArrayExchangeValuesAtIndices(CFMutableArrayRef theArray, CFIndex idx1, CFIndex idx2);
  622.  
  623. /*
  624.     @function CFArraySortValues
  625.     Sorts the values in the array using the given comparison function.
  626.     @param theArray The array whose values are to be sorted. If this
  627.         parameter is not a valid mutable CFArray, the behavior is
  628.         undefined.
  629.     @param range The range of values within the array to sort. If the
  630.         range location or end point (defined by the location plus
  631.         length minus 1) are outside the index space of the array (0
  632.         to N-1 inclusive, where N is the count of the array), the
  633.         behavior is undefined. If the range length is negative, the
  634.         behavior is undefined. The range may be empty (length 0).
  635.     @param comparator The function with the comparator function type
  636.         signature which is used in the sort operation to compare
  637.         values in the array with the given value. If this parameter
  638.         is not a pointer to a function of the correct prototype, the
  639.         the behavior is undefined. If there are values in the array
  640.         which the comparator function does not expect or cannot
  641.         properly compare, the behavior is undefined. The values in
  642.         the range are sorted from least to greatest according to
  643.         this function.
  644.     @param context A pointer-sized user-defined value, which is passed
  645.         as the third parameter to the comparator function, but is
  646.         otherwise unused by this function. If the context is not
  647.         what is expected by the comparator function, the behavior is
  648.         undefined.
  649. */
  650. CF_EXPORT
  651. void CFArraySortValues(CFMutableArrayRef theArray, CFRange range, CFComparatorFunction comparator, void *context);
  652.  
  653. /*
  654.     @function CFArrayAppendArray
  655.     Adds the values from an array to another array.
  656.     @param theArray The array to which values from the otherArray are to
  657.         be added. If this parameter is not a valid mutable CFArray,
  658.         the behavior is undefined. If the array is a fixed-capacity
  659.         array and adding range.length values from the otherArray
  660.         exceeds the capacity of the array, the behavior is
  661.         undefined.
  662.     @param otherArray The array providing the values to be added to the
  663.         array. If this parameter is not a valid CFArray, the
  664.         behavior is undefined.
  665.     @param otherRange The range within the otherArray from which to add
  666.         the values to the array. If the range location or end point
  667.         (defined by the location plus length minus 1) are outside
  668.         the index space of the otherArray (0 to N-1 inclusive, where
  669.         N is the count of the otherArray), the behavior is
  670.         undefined. The new values are retained by the array using
  671.         the retain callback provided when the array was created. If
  672.         the values are not of the sort expected by the retain
  673.         callback, the behavior is undefined. The values are assigned
  674.         to the indices one larger than the previous largest index
  675.         in the array, and beyond, and the count of the array is
  676.         increased by range.length. The values are assigned new
  677.         indices in the array from smallest to largest index in the
  678.         order in which they appear in the otherArray.
  679. */
  680. CF_EXPORT
  681. void CFArrayAppendArray(CFMutableArrayRef theArray, CFArrayRef otherArray, CFRange otherRange);
  682.  
  683. #if defined(__cplusplus)
  684. }
  685. #endif
  686.  
  687. #endif /* ! __COREFOUNDATION_CFARRAY__ */
  688.  
  689.